# 努力学习
# 比肩漆时祺和周期许
# import unittest
# import requests
# class IhrmTest(unittest.TestCase):
#     def login_ok(self):
#         resp=requests.post(url='xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
#                       json={"mobile":"18975767680","password":"888888"})
#         self.assertEqual(200,resp.status_code)
#         self.assertEqual(True,resp.json().get('success'))
#         self.assertEqual(10000,resp.json().get('code'))
#         self.assertEqual('操作成功',resp.json().get('message'))
#     def login_phone_err(self):
#         resp=requests.post(url='xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
#                       json={"mobile":"1897576768","password":"888888"})
#         self.assertEqual(200,resp.status_code)
#         self.assertEqual(False,resp.json().get('success'))
#         self.assertEqual(100001,resp.json().get('code'))
#         self.assertEqual('帐号和密码错误',resp.json().get('message'))
#     def login_pwd_err(self):
#         resp=requests.post(url='xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
#                       json={"mobile":"18975767680","password":"88888"})
#         self.assertEqual(200,resp.status_code)
#         self.assertEqual(False,resp.json().get('success'))
#         self.assertEqual(100001,resp.json().get('code'))
#         self.assertEqual('帐号和密码错误',resp.json().get('message'))

#商城项目普通方法实现
import unittest
import requests
from common.test_schema import schema
import jsonschema
# 定义类
class LoginTest(unittest.TestCase):
# 定义测试方法
    def test_login_01(self):
# 创建session发送post请求
        session=requests.session()
        resp=session.post(url='http://127.0.0.1:8888/api/private/v1/login',
                          json={"username":"admin","password":"123456"}
                          )
        print(resp.json())
        self.assertEqual(200,resp.status_code)
        jsonschema.validate(instance=resp.json(),schema=schema)
# 断言
#         self.assertEqual('登录成功',resp.json().get('meta').get('msg'))
if __name__ == '__main__':
    unittest.main()
















